/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package address;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.RandomAccessFile;
import java.util.ArrayList;

/**
 *
 * @author Administrator
 */
public class Outputpeople {

    Outputpeople(ArrayList contacts,ArrayList belongs) throws IOException{  
        int i;
        
        File f1=new File("belongs.txt");
        File f2=new File("contacts.txt");
        RandomAccessFile inout=null;
        inout=new RandomAccessFile(f1,"rw");
        inout.setLength(0);
        inout.close();
        ObjectOutputStream output=null;
        
        output=new ObjectOutputStream(new FileOutputStream(f1,true));
        for(i=0;i<belongs.size();i++){
            output.writeObject((String)belongs.get(i));
        }       
        output.close();
        inout=new RandomAccessFile("contacts.txt","rw");
        inout.setLength(0);
        inout.close();
        output=new ObjectOutputStream(new FileOutputStream(f2,true));
        for(i=0;i<contacts.size();i++){
          output.writeObject((People)contacts.get(i));
        }
        output.close();
    }
}
